//////////////////////////////////////////////////////////////////////////////////
//	Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#ifndef _STAT_CTRL_H_
#define _STAT_CTRL_H_

#include "def.h"

class CStatCtrl: public wxPanel
{
public:
								CStatCtrl(wxWindow* pParent,const wxString& strLabel, STATMAP& stat);
	virtual						~CStatCtrl(void);
	void						Update();

protected:
	void						DrawBorder(class wxMemoryDC& dc);
	void						DrawTitle(class wxMemoryDC& dc);
	void						DrawStat(class wxMemoryDC& dc);
	void						CalculateTotal();

	void						OnSize(wxSizeEvent& event);
	void						OnPaint(wxPaintEvent& event);
	void						OnMouseMove(wxMouseEvent& event);
	void						OnMouseLeave(wxMouseEvent& event);
	void						OnMenu(wxMouseEvent& event);
	void						OnCopy(wxCommandEvent& event);

	DECLARE_EVENT_TABLE()

protected:
	wxString					m_strLabel;
	STATMAP&					m_stat;
	unsigned int				m_nTotal;
	wxCoord						m_yHeaderLast;

	typedef struct tagSTATPAIR
	{
		wxString str;
		unsigned int val;
		bool operator<(const tagSTATPAIR& pair)
		{
			return val>pair.val;
		}

	}STATPAIR;

	typedef std::list<STATPAIR>	STATPAIRS;

	STATPAIRS	m_pairs;
	int			m_x, m_y;
	STATPAIR	m_cur;
	bool		m_bValid;
};

#endif //_STAT_CTRL_H_